
#include "gtk.h"
#include "../jncTypeConversion.h"
#include "../jncImportNamespace.h"
#include "libglademm/xml.h"
#include "gtkmm.h"


typedef Gtk::Main     Main;
typedef Glib::RefPtr<Gnome::Glade::Xml>     RefPtr;

class GtkMain: public JncInterface {
  JNCINTERFACEIMPL(GtkMain, Main)
    public:
  gReturnCode ConsGtkMain(jncTypev, jncTypev);
  gReturnCode cbRun();
  gReturnCode exRun();
 private:
};

class GlibRefPtr: public JncInterface {
  JNCINTERFACEIMPL(GlibRefPtr, RefPtr)
    public:
  gReturnCode ConsGlibRefPtr(jncTypev v);
 private:
};

gReturnCode GtkMain::ConsGtkMain(jncTypev v, jncTypev w) {
  try {
    char** a = jcmp<char**>(w);
    int c = jint(v);
    return gReturnCode(new Main(c, a));
  }catch(boost::bad_any_cast&) {
    throw;
  }
}

gReturnCode GtkMain::cbRun() {
  typedef gReturnCode (GtkMain::*fnShow)();
  return gReturnCode(new fnShow(&GtkMain::exRun));
}
gReturnCode GtkMain::exRun() {
  __inst->run();
  return gReturnCode();
}

gReturnCode GlibRefPtr::ConsGlibRefPtr(jncTypev v) {
  try {
    Glib::RefPtr<Gnome::Glade::Xml> tmp(Gnome::Glade::Xml::create(std::string(jcmp<char*>(v))));
    return gReturnCode(new Glib::RefPtr<Gnome::Glade::Xml>(tmp));
  }catch(boost::bad_any_cast&) {
    throw;
  }
}

// void getGtkNamespace() {
//   static boost::shared_ptr<GtkMain> ptr_gtk_main(new GtkMain());
//   static boost::shared_ptr<GlibRefPtr> ptr_glib_ref_ptr(new GlibRefPtr());
//   exportObjectHandle<GtkMain>(
// 			      get_pointer(ptr_gtk_main),
// 			      (const char* [JINC_MAX_ARG]){"GtkMain", "int", "p_token", NULL},
// 			      (jncTypei [JINC_MAX_ARG]){JCMP, JCMP, JCMP},
// 			      &GtkMain::ConsGtkMain,
// 			      NORMAL
// 			      );
//   exportObjectHandle<GtkMain>(
// 			      get_pointer(ptr_gtk_main),
// 			      (const char* [JINC_MAX_ARG]){"run", NULL},
// 			      (jncTypei [JINC_MAX_ARG]){JCMP},
// 			      &GtkMain::cbRun,
// 			      &GtkMain::exRun,
// 			      NORMAL
// 			      );
//   exportObjectHandle<GlibRefPtr>(
// 				 get_pointer(ptr_glib_ref_ptr),
// 				 (const char* [JINC_MAX_ARG]){"RefPtr", "xml"},
// 				 (jncTypei [JINC_MAX_ARG]){JCMP, JCMP},
// 				 &GlibRefPtr::ConsGlibRefPtr,
// 				 LOW
// 				 );
// }


